home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxcode / sbmixer / sbmixer.pas < prev   
Pascal/Delphi Source File  |  1994-12-10  |  3KB  |  100 lines

  1. unit SBMixer;
  2.     interface
  3.         type
  4.             ThreeBit=0..7;
  5.             Nibble=0..15;
  6.         type
  7.             InputSource=0..3;
  8.         const
  9.             inpMicDefault = 0;
  10.             inpCDAudio    = 1;
  11.             inpMicrophone = 2;
  12.             inpLineIn     = 3;
  13.  
  14.         type
  15.             FilterSelect=0..7;
  16.         const
  17.             LowFilter  = 0;
  18.             HighFilter = 1;
  19.             NoFilter   = 4;
  20.  
  21.         type
  22.             VoiceMode=0..1;
  23.         const
  24.             Mono   = 0;
  25.             Stereo = 1;
  26.  
  27.         procedure ResetMixer;
  28.         procedure SetMicVolume(Volume: ThreeBit);
  29.         procedure SetInputSettings(Source: InputSource; Filter: FilterSelect);
  30.         procedure SetOutputSettings(DNFI: boolean; Mode: VoiceMode);
  31.         procedure SetMasterVolume(Left, Right: Nibble);
  32.         procedure SetVoiceVolume(Left, Right: Nibble);
  33.         procedure SetFMVolume(Left, Right: Nibble);
  34.         procedure SetCDVolume(Left, Right: Nibble);
  35.         procedure SetLineinVolume(Left, Right: Nibble);
  36.     implementation
  37.         uses
  38.             CRT;
  39.         const
  40.             MixerAddrPort = $224;
  41.             MixerDataPort = $225;
  42.         procedure WriteMixer(Register: byte; Value: byte);
  43.             begin
  44.                 Port[MixerAddrPort] := Register;
  45.                 Delay(1);
  46.                 Port[MixerDataPort] := Value;
  47.                 Delay(1);
  48.             end;
  49.         function ReadMixer(Register: byte): byte;
  50.             begin
  51.                 Port[MixerAddrPort] := Register;
  52.                 Delay(1);
  53.                 ReadMixer := Port[MixerDataPort];
  54.                 Delay(1);
  55.             end;
  56.  
  57.         procedure ResetMixer;
  58.             begin
  59.                 WriteMixer($00, $FF);
  60.                 Delay(10);
  61.             end;
  62.  
  63.         procedure SetMicVolume(Volume: ThreeBit);
  64.             begin
  65.                 WriteMixer($0A, Volume);
  66.             end;
  67.         procedure SetInputSettings(Source: InputSource; Filter: FilterSelect);
  68.             begin
  69.                 WriteMixer($0C, (Source shl 1) + (Filter shl 3));
  70.             end;
  71.         procedure SetOutputSettings(DNFI: boolean; Mode: VoiceMode);
  72.             var
  73.                 Out: byte;
  74.             begin
  75.                 Out := 0;
  76.                 if DNFI then Out := Out + 32;
  77.                 Out := Out + (Mode shl 1);
  78.                 WriteMixer($0E, Out);
  79.             end;
  80.         procedure SetMasterVolume(Left, Right: Nibble);
  81.             begin
  82.                 WriteMixer($22, (Left shl 4) + Right);
  83.             end;
  84.         procedure SetVoiceVolume(Left, Right: Nibble);
  85.             begin
  86.                 WriteMixer($04, (Left shl 4) + Right);
  87.             end;
  88.         procedure SetFMVolume(Left, Right: Nibble);
  89.             begin
  90.                 WriteMixer($26, (Left shl 4) + Right);
  91.             end;
  92.         procedure SetCDVolume(Left, Right: Nibble);
  93.             begin
  94.                 WriteMixer($28, (Left shl 4) + Right);
  95.             end;
  96.         procedure SetLineinVolume(Left, Right: Nibble);
  97.             begin
  98.                 WriteMixer($2E, (Left shl 4) + Right);
  99.             end;
  100.     end.